var str = '';
$(function() {
	sessionStorage.removeItem('type');
})

$('.main-info a.mui-btn').on('tap', function() {
	sessionStorage.setItem('type',1);
    location.href=MPJ.base+"/pages/account/receiver/add.jsp";
})
$('.yourOrder h1').on('tap', function() {
    var $listBox = $('.yourOrder .orderList');
    var $img = $('.yourOrder h1 span img');
    if ($listBox.css('display') == "none") {
        $listBox.slideDown();
        $img.attr('src', MPJ.base+'/resources/images/icon/delivery-jt-up.png');
    } else {
        $listBox.slideUp();
        $img.attr('src', MPJ.base+'/resources/images/icon/delivery-jt-down.png');
    }
})

$('.deleteBtn').each(function(index) {
    $(this).on('tap', function() {
        $('.yourOrder .orderList .item').eq(index).remove();
    })

})

//时间段选择
$('.time-section label').on('tap',function(){
	if($(this).hasClass('usable')){
		$('.time-section label').removeClass('active');
		$(this).addClass('active');
	}
})
//单选按钮点击
$('.checkBox').on('tap', function() {
    var $src = $(this).find('span img');
    if ($(this).hasClass('active')) {
        $src.attr('src', MPJ.base+'/resources/images/icon/delivery-no-select.png');
        $(this).removeClass('active');
    } else {
        $src.attr('src', MPJ.base+'/resources/images/icon/delivery-select.png');
        $(this).addClass('active')
    }
})


$('.btnBox .payMent').on('tap', function() {
    $('#screen').show();
})
$('.alert-title span').on('tap', function() {
    $('#screen').hide();
})
//配送方式选择
$('.hasLogin #method').change(function(){
	var str=$('#method').val();
    if (str == "Delivery") {
    	$('.hasLogin').removeClass('on');
    }else if (str == "Store pick up") {
        dialog('Select Pick-up Location', '<select id="address" class="select"><option value="Marina Cove (Sai Kung) (Sai Kung...">Marina Cove (Sai Kung) (Sai Kung...</option><option value="Marina Cove (Sai Kung) (Sai Kung...">Marina Cove (Sai Kung) (Sai Kung...</option></select>', 1);
        var $dialog = $('#dialog');
        $dialog.show();
        $('.weui_dialog_ft').addClass('setWidth');
        $dialog.find('.comfirmBtn').one('click', function() {
            $dialog.hide();
            $dialog.remove();
        	$('.hasLogin').addClass('on');
        });
        
    }
})
$('#pickerBox').change(function(){
	 dialog('Select Pick-up Location', 'You previously selected Delivery Service. If you change the delivery method, some products may become unavailable. Would you like to proceed?', 3);
    var $dialog = $('#dialog');
    $dialog.show();
    $dialog.find('.comfirmBtn').one('click', function() {
        $dialog.hide();
        $dialog.remove();
    
    });
})


function getLocationDate(){
	$('.selectCate .name').html($('#pickerBox .name').html());
	$('.selectCate .address').html($('#pickerBox .address').html());
	$('.selectCate .phone').html($('#pickerBox .phone').html());
	
}